(define-module (theme theme)
  #:use-module (srfi srfi-19)
  #:use-module (haunt site)
  #:use-module (haunt post)
  #:use-module (utils utils)
  #:export (gnucode-layout
            date->string*
            %meta-sxml-elements
            %header-sxml-element
            %footer-sxml
            %sxml-css-links))

;; (define %bjj-image
;;   '(img (@ (src "bjj.webp") (alt "Plainfield Brazilian Jiu Jitsu logo"))))

(define (date->string* date)
  "Convert DATE to human readable string."
  (date->string date "~B ~d, ~Y"))

(define (gnucode-layout site title body)
  `((doctype "html")
    (head
     ,%meta-sxml-elements
     ,%sxml-css-links
     (title ,(string-append title " — " (site-title site))))
    (body
     ,%header-sxml-element
     ,(if (string=? "Recent Posts" title)
          `(h1 ,(site-title site))
          `(h1 ,title))
     (main
      ,body)
     ,%footer-sxml
     )))

(define %header-sxml-element
  `((header
     (div (@ (class "header header-fixed"))
          (div (@ (class "navbar"))
               (div (@ (class "logo"))
                    (a (@ (href "index.html")) "Home"))
               (input (@ (type "checkbox") (id "navbar-toggle")))
               (label (@ (for "navbar-toggle")) (i ()))
               (nav (@ (class "menu"))
                    (ul
                     (li (@ (class "hidden-md")) (a (@ (href "index.html")) "Home"))
                     (li (a (@ (href "money-raised.html")) "Money Raised"))
                     )))))))

(define %sxml-css-links
  '((link (@ (type "text/css") (href "css/footer.min.css") (rel "stylesheet")) "")
    (link (@ (type "text/css") (href "css/header.min.css") (rel "stylesheet")) "")
    (link (@ (type "text/css") (href "css/main.min.css") (rel "stylesheet")) "")
    (link (@ (type "text/css") (href "css/basic.min.css") (rel "stylesheet")) "")
    (link (@ (type "text/css") (href "css/gallery.min.css") (rel "stylesheet")) "")
    ))

(define %meta-sxml-elements
  '((meta (@ (charset "utf-8")))
    ;; this tells mobile phones to render the viewport as large as the phone.
    (meta (@ (name "viewport") (content "width=device-width, initial-scale=1")))
    (meta (@ (name "keywords") (content "slavery proper naming")))
    (meta (@ (name "description")
             (content "Not virtue signaling to end slavery.")))
    (meta (@ (property "og:title") (content "Proper Naming Initiative")))
    (meta (@ (property "og:description") (content "Not virtue signaling to end slavery.")))
    ;; TODO https://static.wixstatic.com/media/857da9_7f9b0e10f9e148b895fd851e58946c4f%7Emv2.png/v1/fit/w_2500,h_1330,al_c/857da9_7f9b0e10f9e148b895fd851e58946c4f%7Emv2.png
    (meta (@ (property "og:image") (content "")))
    (meta (@ (property "og:url") (content "https://www.propernaming.org")))
    (meta (@ (property "og:site_name") (content "Proper Naming")))
    (meta (@ (property "og:type") (content "website")))
    ))
(define %footer-sxml
  `((footer
     (div
      )
     (section (@ (class "background-grey copyright"))
              (p "©2020 by Proper Naming Initiative. " )))))
